<template>
    <div id="cutting">
         <!-- ----------------没有砍价页面 --------------- -->
        <div id="shopping-empty" :style="{height:height+'px'}" type="1" v-if="showTime">
		    <img src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/orders_empty.png" class="empty-bg" />
		    <span>还没有相关订单呢～</span>
		    <input type="button" class="goHome" value="今日推荐" @click="gohome()" />
	    </div>
        <!-- ---------------- 砍价中列表 --------------- -->
        <div class="allDiv" v-else>
			<div class="two" style="background:white;" v-for="x in list" >
				<div class="contest" :id="x.shopInfo.id" >
					<ul class="left" @click="goBussiness(x.shopInfo.id)">
						<li class="text"><img :src="x.shopInfo.logo" style="width:.4rem;height:.4rem;border-radius:50%;margin-right:.1rem;">{{x.shopInfo.name}}<img src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/more@2x.png" style="width: 0.14rem;height: 0.26rem;margin-left: .12rem;"></li>
					</ul>
                    <ul class="right">
						<li class="success">正在砍价</li>
					</ul>
				</div>
				<div class="cutDetail" @click="goOrderdetails($event)" :orderid="x.orderid">
					<ul class="photo">
						<li><img :src="x.proInfo.thumb"></li>
					</ul>
					<ul class="cut-right">
						<li class="one" style="-webkit-box-orient: vertical;">{{x.proInfo.title}}</li>
						<li class="two">{{x.proInfo.spec}} </li>
						<li class="three">
							<span class="icon" >¥</span>
							<span class="money">{{x.proInfo.minPrice}}</span>&nbsp;&nbsp;
							<span class="before" style="text-decoration: line-through; font-size:.24rem; color:#969696">¥{{x.proInfo.maxPrice}}</span>
							<span style="float:right;">X{{x.proInfo.buyNum}}</span>
						</li>
					</ul>
				</div>
                <div class="cut-btn">
					<p class="allMoney">共<span>{{x.proInfo.buyNum}}</span>件商品 总价 : ¥ <span>{{x.proInfo.minPrice}}</span>(包邮)</p >
					<div class="btn">
						<button v-for="(z,y) in x.byType.btType"  :type="z.type"  @click="toPayState($event,x.cutType)" :keys="z.key" :orderid="x.orderid">{{z.key | status}}</button>
					</div>
				</div>
            </div>
		</div>
    </div>
</template>

<script>
    import config from "../config/config.js";
    import MtaH5 from 'mta-h5-analysis';
    export default{
        data(){
            return{
                showTime:Boolean,
                list:[]
            }
        },
        methods:{
            gohome(){
                this.$router.push("/home/index/00")
            },
            toPayState($event,x){
                var e=$event.currentTarget,
                    keys=e.getAttribute('keys'),
                    orderid=e.getAttribute('orderid');
                this.x = x;
                if(keys=='SHOW_DETAILS'){
                  if(x==1){
                    this.$router.push('/oneKan/'+orderid)
                  }else if(x==2){
                    this.$router.push('/threekan/'+orderid)
                  }else{
                    this.$router.push('/freekan/'+orderid)
                  }
                }
            },
            GetOrderInfo(type){
                var value=JSON.stringify({"page":"1","type":type,"token":localStorage.getItem('token')}),
                    key=demo(value);
                axios.post('/Home/Order/GetOrderInfo',{
                        value:value,
                        key:key
                },config)
                    .then(function(response) {
                        if(response.data.data.data==''){
                            this.showTime=true;
                        }else{
                            this.showTime=false;
                            this.list=response.data.data.data;
                        }
                    }.bind(this))
                    .catch(function (error) {
                        console.log(error);
                    });
			},
            goOrderdetails($event){
                var e=$event.currentTarget,
                    orderid=e.getAttribute('orderid'),
                    type='B';
				this.$router.push('/orderdetail/'+orderid+'/'+type)
            },
            goBussiness(id){
                this.$router.push('/business/'+id)
            },
        },
        filters:{
            status:function(val){
                switch(val){
                    case 'CANCEL_ORDER':
                        return "取消订单";
                    case 'PAY_ORDER':
                        return "付款";
                    case 'URGE_ORDER':
                        return "催发货";
                    case 'EXTEND_ORDER':
                        return "延长收货";
                    case 'SHOW_LOGISTICS':
                        return "查看物流";
                    case 'SURE_ORDER':
                        return "确认收货";
                    case 'DELETE_ORDER':
                        return "删除订单";
                    case 'AFTER_BUY':
                        return "申请售后";
                    case 'REMARK_ORDER':
                        return "评价";
                    case 'UPDATE_REFUND':
                        return "修改申请";
                    case 'CANCEL_REFUND':
                        return "撤销申请";
                    case 'APPLY_PLATFORM_IN':
                        return "申请砍好货介入";
                    case 'AGAIN_REFUND':
                        return "重新申请";
                    case 'UPDATE_REMARK':
                        return "追评";
                    case 'FAX_LOGISTICS':
                        return "填写退货物流";
                    case 'SHOW_DETAILS':
                        return '查看详情';
                }
            }
        },
		activated(){
            this.GetOrderInfo('B');
            MtaH5.init({
                "sid":'500594815',
                "cid":'500595819',
                "autoReport":0,
                "senseHash":0,
                "senseQuery":0,
                "performanceMonitor":0,
                "ignoreParams":[]
            });
            MtaH5.pgv();
		},
        mounted(){
            this.$nextTick(function () {
                var windowH=window.screen.height;
                this.height=windowH;
            })
        },

    }
</script>

<style>
    
</style>>